package com.imstlife.vending.dialog;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;

import com.imstlife.vending.R;
import com.imstlife.vending.adapter.KeyAdapter;

public class PasswordDialog extends Dialog {




    private static PasswordDialog ins;

    public static PasswordDialog getIns(Context context){
        if(ins==null){
            synchronized (PasswordDialog.class){
                if(ins==null) {
                    ins = new PasswordDialog(context);
                }
            }
        }
        return ins;
    }


    private PasswordDialog(@NonNull Context context) {
        super(context);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(customView(context));

    }

    public PasswordDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(customView(context));

    }

    public PasswordDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(customView(context));
    }

    private View customView(Context context){
        View view =  View.inflate(context,R.layout.dialog_pwd,null);
        RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rv_dialog_pwd);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(context,3);
        recyclerView.setLayoutManager(gridLayoutManager);
        KeyAdapter keyAdapter= new KeyAdapter();
        recyclerView.setAdapter(keyAdapter);
        return view;

    }



}
